
function checkall(form, refer, prefix) {
	var form = document.getElementById(form);
	for(var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		switch(refer.name) {
			case "chkall":value = true;break;
			case "unchkall":value = false;break;
			case "opposite":value = !e.checked;break;
			default :value = refer.checked;
		}
		if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) e.checked = value;
	}
}

var B = new Object();
	B.IE = window.ActiveXObject ? true : false;


function $$(objId){
	return document.getElementById(objId);
}


function cfmoption(word, loc){
	if(confirm(word)) location.href = loc;
}

function cstrlen(str){
	var tmp = 0;
	for(var i = 0; i < str.length; i++) {
		tmp += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? 2 : 1;
	}
	return tmp;
}

function classFocus(input){
	input.parentNode.className = 'fnz_li_on';
}

function classBlur(input){
	input.parentNode.className = '';
}

function rawurlencode(str){
	return encodeURIComponent(str);
}

function _cookie(cookieName) {
	var cookieString = document.cookie;
	var start = cookieString.indexOf(cookieName + '=');// 加上等号的原因是避免在某些 Cookie 的值里有与 cookieName 一样的字符串。
	if (start == -1) return null;// 找不到
	start += cookieName.length + 1;
	var end = cookieString.indexOf(';', start);
	var c='';
	if (end == -1) c = unescape(cookieString.substring(start));
	else c = unescape(cookieString.substring(start, end));
	if (c && c.length>3096){
		return null;
	}
	return explode(c);
}

function cookie(objName,objValue,objHours){//添加cookie
	if (is_array(objValue)){
		objValue = implode(objValue);
	}
	if (objValue && objValue.length>3096){
		objValue='';//過大則清空
	}
	var str = objName + "=" + escape(objValue);
	var date = new Date();
	if(objValue){//为0时不设定过期时间，浏览器关闭时cookie自动消失
		if (!objHours) objHours=720;
		var ms = objHours*3600*1000;
		date.setTime(date.getTime() + ms);
	}else{
		date.setTime(date.getTime() - 10000);
	}
	str += "; expires=" + date.toGMTString();
	document.cookie = str;
}

function is_array(test){
	if(typeof test == 'object' && typeof test.sort == 'function' && typeof test.length == 'number'){
		return true;
	}else{
		return false;
	}
}

//合并數組(無法保留索引)
function implode(obj,sep){
	if (!is_array(obj)) return obj;
	if (!sep) sep=0;
	var special="#aokosoft"+sep+"#";
	sep++;
	//簡單的遞歸處理
	for (var i in obj){
		if (is_array(obj[i])){
			obj[i]=implode(obj[i],sep);
		}else{
			//obj[i]=obj[i].replace(/#aokosoft/,'');
		}
	}
	obj = obj.join(special);
	return obj;
}

//分割數組
function explode(obj,sep){
	if (!sep) sep=0;
	var special="#aokosoft"+sep+"#";
	var start = obj.indexOf('#aokosoft');
	sep++;
	if (start != -1 && sep<=10) {
		obj=obj.split(special);
		for (var i in obj){
			start = obj[i].indexOf('#aokosoft');
			if (start != -1) obj[i]=explode(obj[i],sep);
		}
	}
	return obj;
}

//显示隐藏
function showhide(show,id){
	if(show) {
		$$('_S_H'+id).style.display = '';
	}else {
		$$('_S_H'+id).style.display = 'none';
	}
}

//评论相关
function commentquote(id){
	$('#quoteid').val(id);
	$('#quoteidspan').html('引用'+id+'楼');
	$('#quoteid').attr("checked", true);
}
function checkempty(){
	if ($('#luf_comment_mytitle').val()=='在此输入评论标题'){
		$('#luf_comment_mytitle').val('');
	}
	if ($('#luf_comment_post').val()=='在此输入评论内容' || !$('#luf_comment_post').val() || $('#luf_comment_post').val().length<{minlength}){
		alert('未输入内容或内容输入太短');
		return false;
	}
}
